import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:cupertino_icons/cupertino_icons.dart';
import 'package:get/get.dart';

class UserHeader extends StatelessWidget {
  final String username;
  final String sign;
  final String intro;
  final String avatar;
  final bool news_tap;

  UserHeader({
    Key key,
    this.username,
    this.sign = "",
    this.intro,
    this.avatar,
    this.news_tap = false,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
//      height: 80,
        child: Column(
      children: [
        Container(
            margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(
                  "我的",
                  style: TextStyle(
                    decoration: TextDecoration.underline,
                    decorationStyle: TextDecorationStyle.dashed,
                    decorationColor: Colors.blueGrey[200],
                    fontWeight: FontWeight.bold,
                    fontSize: 20,
                  ),
                ),
                Container(
//                  width:, 这里还需要一个getx获取的屏幕的宽度和屏幕的高度
                    child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Container(
                      width: 25,
                      height: 24,
                      child: GestureDetector(
                        child: Stack(
                          children: [
                            Align(
                              alignment: Alignment(0, 0),
                              child: Icon(Icons.email, size: 24),
                            ),
                            this.news_tap
                                ? Align(
                                    alignment: Alignment(0.9, -0.8),
                                    child: Container(
                                      width: 7,
                                      height: 7,
                                      decoration: BoxDecoration(
                                          color: Colors.red,
                                          borderRadius: BorderRadius.all(
                                              Radius.circular(5))),
                                    ),
                                  )
                                : Container(),
                          ],
                        ),
                        onTap: () {
                          var that = this;
                          Get.toNamed('/notice_page');
                        },
                      ),
                    ),
                    Icon(
                      Icons.settings,
                      size: 24,
                    )
                  ],
                )),
              ],
            )),
        Row(
          children: [
            Container(
              margin: EdgeInsets.only(left: 15, top: 15),
              child: ClipOval(
                  child: Image.network(
                this.avatar,
                width: 70,
                height: 70,
                fit: BoxFit.cover,
              )),
            ),
            Expanded(
              flex: 1,
              child: Padding(
                padding: EdgeInsets.only(left: 20),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      this.username,
                      style: TextStyle(
                        fontWeight: FontWeight.w500,
                        fontSize: 20,
//                  color: Color.fromARGB(111, 211, 211, 211)
                      ),
                    ),
                    SizedBox(
                      width: 200,
                      height: 15,
                    ),
                    GestureDetector(
                      child: Row(
                        children: [
                          Text(
                            '编辑资料 ',
                            style: TextStyle(
                                color: Color.fromARGB(100, 0, 0, 0),
                                fontSize: 13),
                          ),
                          Icon(
                            Icons.border_color,
                            size: 13,
                          )
                        ],
                      ),
                      onTap: () {
                        Get.toNamed('/revise_info');
                      },
                    )
                  ],
                ),
              ),
            ),
            Container(
              margin: EdgeInsets.only(right: 20),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Icon(
                    CupertinoIcons.right_chevron,
                    size: 15,
                  )
                ],
              ),
            ),
          ],
        ),
      ],
    ));
  }
}
